#include <iostream>
#include <list>
#include <vector>

using namespace std;

void test_vector() {
  vector<int> v_int{1, 2, 3, 4, 5};
  vector<char> v_char{1, 2, 3, 4, 5};
  for (auto&& i : v_int) {
    cout << &i << endl;
  }
  for (auto&& i : v_char) {
    cout << (int*)&i << endl;
  }

  vector<vector<int>> v_2d{{1, 2, 3, 4, 5}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5},
                           {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5}, {1, 2, 3, 4, 5}};
  for (auto&& vec : v_2d) {
    for (auto&& i : vec) cout << &i << endl;
  }
}

void test_list() {
  // 创建含整数的 list
  std::list<int> l = {7, 5, 16, 8};

  // 添加整数到 list 开头
  l.push_front(25);
  // 添加整数到 list 结尾
  l.push_back(13);

  // 以搜索插入 16 前的值
  auto it = std::find(l.begin(), l.end(), 16);
  if (it != l.end()) l.insert(it, 42);

  // 迭代并打印 list 的值
  std::cout << "l = { ";
  for (int n : l) std::cout << n << ", ";
  std::cout << "};\n";
}

int main(int argc, char** argv) {
  test_vector();
  test_list();
  return 0;
}